#pragma once

#include "commons.hxx"

#define REGISTER_ACTIONS(site,decision,args) info_syslog("*Register actions, from: '%s.dll(.so)'...\n",TO_STRING(site));CHECK(OUR_register_actions(decision,args))
#define ADD_TYPE_ACTION(business,message,type,func,args) {METHOD_id_t method_id = {0, NULL};\
info_syslog("+Type action - %s: %s.%s\n",business,message,TO_STRING(type));\
CHECK(METHOD_find_method(business,message,&method_id));\
if(ITK_ok == ifail)CHECK(METHOD_add_action(method_id,type,func,args));}
#define ADD_PROP_ACTION(business,name,message,type,func,args) {METHOD_id_t method_id = {0, NULL};\
info_syslog("+Property action - %s.%s: %s.%s\n",business,name,message,TO_STRING(type));\
CHECK(METHOD_find_prop_method(business,name,message,&method_id));\
if(ITK_ok == ifail)CHECK(METHOD_add_action(method_id,type,func,args));}

/// <summary>
/// 业务对象前/后处理
/// </summary>
typedef struct tag_type_action {
	const char* business;
	const char* message;
	METHOD_action_type_t type;
	METHOD_function_t func;
	TC_argument_list_t* args;
} OUR_type_action;

/// <summary>
/// 业务属性前/后处理
/// </summary>
typedef struct tag_prop_action {
	const char* business;
	const char* name;
	const char* message;
	METHOD_action_type_t type;
	METHOD_function_t func;
	TC_argument_list_t* args;
} OUR_prop_action;

/// <summary>
/// 注册 action 方法（主要用于业务对象的前处理或者后处理）
/// </summary>
/// <param name="decision"></param>
/// <param name="args"></param>
/// <returns>是否注册成功</returns>
int OUR_register_actions(int* decision, va_list args);
